package cn.gson.springboot.model.dao;

import cn.gson.springboot.model.pojos.ProductDetail;
import cn.gson.springboot.model.pojos.Quotation;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ProductDetailDao extends CrudRepository<ProductDetail,Integer> {
    //根据quId删除详单
    @Query("delete from ProductDetail p where p.quotationByQuotationId.quotationId = :quotationId")
    @Modifying
    public void deleteByQuId(@Param("quotationId") int quotationId);


    //根据conId(合同订单id)删除详单
    @Query("delete from ProductDetail p where p.contractByContractId.contractId = :contractId")
    @Modifying
    public void deleteByConId(@Param("contractId") int contractId);

    //根据purId删除采购详单
    @Query("delete from ProductDetail p where p.purchaseByPurchaseId.purchaseId = :purchaseId")
    @Modifying
    public void deleteByPurId(@Param("purchaseId") int purchaseId);


}
